import React from 'react'
import {render} from 'react-dom'
import VConsole from 'vconsole'
import './assets/styles/home.scss'
import App from './view/App'
import {Provider} from "react-redux";
import store from './store/index'
import zhCN from 'antd/lib/locale/zh_CN';
import 'moment/locale/zh-cn';
import 'antd/dist/antd.css';
import {ConfigProvider} from 'antd';
import moment from "moment";

moment.locale('zh-cn');
const root = document.getElementById('root')
// const vConsole = new VConsole();
let app = () => (
    <ConfigProvider locale={zhCN}>
        <div className='bg-blur'>
        </div>
        <div className='themes-warp theme-light'>
            <Provider store={store}>
                <App/>
            </Provider>
        </div>
    </ConfigProvider>
)
let alertCmd = alert;
window.alert = (str) => {
    alertCmd(str)
}
// window.onerror = (msg, url, l) => {
//     if (msg == 'ResizeObserver loop limit exceeded') return;
//     // console.error(msg,url,l)
//     let msgNew = msg.substr(msg.indexOf(': ') + 2);
//     if (msgNew.indexOf('_') != 0) {
//         alert(msgNew);
//     }
//     return false;
// }
window.utools = window.utools || {
    onPluginReady() {
    }, onPluginEnter() {
    }, onPluginOut() {
    }
}
let onPluginReadyCallbackList = [];
window.onPluginReady = (fun) => {
    onPluginReadyCallbackList.push(fun);
}
window.utools.onPluginReady(() => {
    onPluginReadyCallbackList.forEach(fun => fun())
})

let onPluginEnterCallbackList = [];
window.onPluginEnter = (fun) => {
    onPluginReadyCallbackList.push(fun);
}
window.utools.onPluginEnter(() => {
    onPluginEnterCallbackList.forEach(fun => fun())
})

render(app(), root);
// render((<a), root);

//状态改变，更新UI
// store.subscribe(() => {
//     render(app(), root);
// })
